import React, { memo } from 'react'
import router from './router/router'
import { useLocation, useNavigate, useRoutes } from 'react-router-dom'
import { useEffect } from 'react'
const App = memo(() => {
  let location = useLocation()
  let navigate = useNavigate()
  let token = localStorage.getItem('token')

  useEffect(() => {
    if (!token && location.pathname !== '/login') {
      navigate('/login')
    }
  }, [location.pathname])
  return (
    <div>
      {useRoutes(router)}
    </div>
  )
})

export default App

